package com.demo.key.pa

import com.demo.key.R
import com.demo.key.load_admob.AdmobKeyType
import com.demo.key.server.ConnectServer0822Manager
import com.demo.key.show_admob.ShowNativeAd0822
import com.demo.key.util.serverFlagRes
import kotlinx.android.synthetic.main.activity_result.*

class Result0822Pa :Abs0822Page(){
    private val showResultNativeAd by lazy { ShowNativeAd0822(this, AdmobKeyType.HOME) }


    override fun layoutId(): Int = R.layout.activity_result

    override fun view() {

        iv_back.setOnClickListener { finish() }

        val countryKey0822 = ConnectServer0822Manager.last.country_key0822
        iv_result_flag.setImageResource(serverFlagRes(countryKey0822))
        val connect = intent.getBooleanExtra("connect", false)
        tv_connect.text=if (connect) "Connected!" else "Disconnected!"
        tv_result_server_name.text=countryKey0822

        iv_flag_bg.setImageResource(
            if (connect) R.drawable.icon_connect_bg
        else R.drawable.icon_disconnect_bg
        )
    }

    override fun onResume() {
        super.onResume()
        showResultNativeAd.loopCheckHasNativeAd()
    }

    override fun onDestroy() {
        super.onDestroy()
        showResultNativeAd.onDestroy()
    }
}